import 'package:boss/models/takeout_order_list_data.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/custom_divier.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class TakeoutOrderPanel extends StatelessWidget {
  final TakeoutOrderItem data;

  const TakeoutOrderPanel({
    Key key,
    this.data,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ShadowRadiusCard(
      margin: EdgeInsets.only(top: 30.w),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            height: 80.w,
            padding: EdgeInsets.symmetric(horizontal: 20.w),
            alignment: Alignment.centerLeft,
            child: Text(
              '订单信息',
              style: TextStyleConstant().normal_3_28,
            ),
          ),
          CustomDivider(),
          Container(
            padding: EdgeInsets.all(
              20.w,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                _RowValue('下单时间', data.ctime),
                _RowValue('订单编号', data.takeOutId),
                _RowValue('订单备注', data.remark),
                if (data.pickupCode != null) _RowValue('取件码', data.pickupCode),
                if (data.refundOrderReason != null) _RowValue('退款原因', data.refundOrderReason),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

class _RowValue extends StatelessWidget {
  final String title;
  final String value;

  const _RowValue(this.title, this.value);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 10.w),
      child: Text(
        '$title：$value',
        style: TextStyleConstant().normal_2_26,
      ),
    );
  }
}
